#!/usr/bin/env python
# coding=utf-8
# __author__ = 'Yunchao Ling'

from pathlib import Path
import os

path=Path("D:\public_data_download\previous_list")

for file in path.iterdir():
    if not file.name.endswith("runid"):
        infile=open(file.resolve(),"r")
        outfile=open(str(file.resolve())+".runid","w")
        for line in infile:
            line=line.rstrip()
            if line.startswith("/"):
                runid=line.split("/")[-1][:-4]
                outfile.write(runid+"\n")
                outfile.flush()
        outfile.close()
        infile.close()
        os.remove(file.resolve())